<template>
    <el-menu
        class="el-menu-vertical-demo"
        router
        :collapse="!isshow"
        :collapse-transition="false"
    >
        <el-menu-item index="/">
            <el-icon><House /></el-icon>
            <span>首页</span>
        </el-menu-item>

        <el-sub-menu
            v-for="item in list"
            :key="item.name"
            :index="'/' + item.name"
        >
            <template #title>
                <el-icon><location /></el-icon>
                <span> {{ item.label }} </span>
            </template>
            <el-menu-item
                v-for="child in item.children"
                :key="child.label"
                :index="'/' + item.name + '/' + child.name"
                >{{ child.label }}</el-menu-item
            >
        </el-sub-menu>
    </el-menu>
</template>

<script>
import { Location, House } from "@element-plus/icons-vue";
import { routes } from "../router";
export default {
    props: ["isshow"],
    components: {
        Location,
        House,
    },
    data() {
        return {
            routesList: routes[0].children,
        };
    },
    computed: {
        list() {
            return this.$store.state.userInfo.adminname !== "admin"
                ? this.$store.state.userInfo.checkedkeys
                : this.routesList;
        },
    },
};
</script>
